package net.xdclass.springboot.demo;

import net.xdclass.springboot.SpringbootApplication;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.MvcResult;

@RunWith(SpringRunner.class)
@SpringBootTest(classes={SpringbootApplication.class})
@AutoConfigureMockMvc
public class MockMVCTestDemo {

    @Autowired
    private MockMvc mockMvc;

    @org.junit.Test
    public void test1() throws Exception {
        MvcResult mvcResult = mockMvc.perform(org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get("/v1/page_user1").param("from", "123").param("size","567"))
                .andExpect(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status().isOk())
                .andReturn();
        int starus = mvcResult.getResponse().getStatus();
        System.out.println(starus);
        System.out.println(mvcResult.getResponse().getContentAsString());
    }

}
